<?php

class Adept_Template_Attribute_Constant extends Adept_Template_Attribute_Abstract
{

    protected $value;

    protected static $transformTable = null;

    public function __construct($value = null) 
    {
    	$this->value = $value;
    }	
    
    public function getValue()
    {
        static $transTable;
        if (is_null(self::$transformTable)) {
            self::$transformTable = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES));
        }

        if (!is_null($this->value)) {
            return strtr($this->value, self::$transformTable);
        }
        return $this->value;
    }

    public function setValue($value)
    {
        $this->value = $value;
    }
    
    public function generate($writer) 
    {
    	$writer->writePhpLiteral($this->value);
    }	

}
